home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10634 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: in1.uu.net!interaccess!usenet
  2. From: brianmcg@interaccess.com (Brian V. McGroarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Could someone help me with this imbedded assembly code
  5. Date: 19 Mar 1996 01:59:42 GMT
  6. Organization: Internet Squire
  7. Message-ID: <4il4ee$m77@nntp.interaccess.com>
  8. References: <4ikm39$g8b@host-3.cyberhighway.net>
  9. Reply-To: brianmcg@interaccess.com
  10. NNTP-Posting-Host: d48-isdn.nhe.interaccess.com
  11. X-Newsreader: Internet Squire 1.20
  12.  
  13. I believe that you're going to need to pull the labels out of the assembly
  14. section and explicitly return the contents of ax.  The modified function
  15. would read:
  16.  
  17. unsigned char scankey(void)
  18. {
  19.     unsigned char keyFound;
  20.  
  21.     asm {
  22.         mov ah, 01h
  23.         int 16h
  24.         jz empty;
  25.         mov ah, 00h
  26.         int 16h
  27.         mov al, keyFound
  28.     }
  29. empty:
  30.     return( keyFound );
  31. }
  32.  
  33.  
  34.  
  35. lassiter wrote:
  36. >#include <iostream.h>
  37. >
  38. >unsigned char scankey(void)
  39. >{
  40. > asm{
  41. >  mov ah, 01h
  42. >  int 16h
  43. >  jz empty;
  44. >  mov ah, 00h
  45. >  int 16h
  46. >  mov al, ah
  47. >  xor ah, ah
  48. >  jmp done;
  49. >  empty:
  50. >   xor ax, ax
  51. >  done:
  52. >  }
  53. > }
  54. >
  55. >  Could someone tell me what is wrong with this code?  I am using Borland
  56. >  C++ 3.0.  The errors I am getting are 
  57. >
  58. >            error test.cpp 19: undefined label 'done'
  59. >            error test.cpp 19: undefined label 'empty'
  60. >            warning test.cpp 19: Function should return a value
  61.  
  62.  
  63.  
  64. ---
  65. Brian Valters McGroarty -- brianmcg@bix.com
  66. phone/fax (847) 439-7714
  67.